home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Science / µSim 1.0b5 folder / Libs / UtilsCommon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-03  |  7.5 KB  |  247 lines  |  [TEXT/MMCC]

  1.  
  2. #if defined(FabSystem7orlater)
  3.  
  4. #define    FabFSpOpenResFile    FSpOpenResFile
  5. #define    FabFSpCreate    FSpCreate
  6. #define    FabFSpOpenDF    FSpOpenDF
  7. #define    FabFSpDelete    FSpDelete
  8. #define    FabStandardGetFile    StandardGetFile
  9. #define    FabStandardPutFile    StandardPutFile
  10.  
  11. #else
  12.  
  13. #include    "Utils6.h"
  14.  
  15. #endif
  16.  
  17.  
  18. /*pascal OSErr SetLabel(short labelNumber, const RGBColor *, ConstStr255Param)
  19.     = {0x303C, 0x050C, 0xABC9};
  20. */
  21. /*#pragma parameter __D0 PBEjectAsync(__A0)
  22. pascal OSErr PBEjectAsync(ParmBlkPtr paramBlock)
  23.     = 0xA417; 
  24. */
  25. /* Returns a pointer to the Dialog Manager’s standard dialog filter
  26. pascal OSErr GetStdFilterProc(ModalFilterProcPtr *theProc )
  27.     = { 0x303C, 0x0203, 0xAA68 };
  28.  */
  29. /* Indicates to the Dialog Manager which item is default.  Will then alias the return */
  30. /* & enter keys to this item, and also bold border it for you (yaaaaa!)    
  31. pascal OSErr SetDialogDefaultItem(DialogPtr theDialog, short newItem) 
  32.     = { 0x303C, 0x0304, 0xAA68 };        
  33.  */
  34. /* Indicates which item should be aliased to escape or Command - .
  35. pascal OSErr SetDialogCancelItem(DialogPtr theDialog, short newItem)
  36.     = { 0x303C, 0x0305, 0xAA68 };
  37.  */
  38. /* Tells the Dialog Manager that there is an edit line in this dialog, and */ 
  39. /* it should track and change to an I-Beam cursor when over the edit line
  40. pascal OSErr SetDialogTracksCursor(DialogPtr theDialog, Boolean tracks)
  41.     = { 0x303C, 0x0306, 0xAA68 };
  42.  */
  43. #define topLeft(r)        (((Point *) &(r))[0])
  44. #define botRight(r)        (((Point *) &(r))[1])
  45.  
  46. //pascal Boolean OSSTDFILTERPROC(DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
  47.  
  48. /* a little bit of work Apple should have done in the first place in the headers */
  49.  
  50. /*#pragma parameter __D0 MySetApplLimit(__A0)
  51. pascal short MySetApplLimit(void *zoneLimit)
  52.     = 0xA02D; 
  53. */
  54. /*#pragma parameter __D0 MyDelay(__A0)
  55. pascal long MyDelay(long numTicks)
  56.     = {0xA03B}; 
  57. */
  58. #if USES68KINLINES
  59. #pragma parameter MyNumToString(__D0,__A0)
  60. extern pascal void MyNumToString(long theNum,Str255 theString)
  61.  TWOWORDINLINE(0x4267, 0xA9EE);
  62. #else
  63. #define    MyNumToString    NumToString
  64. #endif
  65.  
  66. /*#pragma parameter __D0 MyStringToNum(__A0)
  67. pascal long MyStringToNum(ConstStr255Param theString) = {0x3F3C, 0x0001, 0xA9EE };
  68. */
  69. /*#pragma parameter __D0 FabDate2Secs(__A0)
  70. pascal long FabDate2Secs(const DateTimeRec *date)
  71.  = _Date2Secs; 
  72. */
  73. /*pascal long FabSndSoundManagerVersion(void)
  74.     = {0x203C,0x000C,0x0008,0xA800}; 
  75. */
  76. /* WantThisHandleSafe locks high the handle and returns the previous state */
  77.  
  78. #if defined(powerc) || defined (__powerc)
  79. SignedByte WantThisHandleSafe(Handle myH);
  80. #else
  81. #pragma parameter __D0 WantThisHandleSafe(__A0)
  82. extern pascal SignedByte WantThisHandleSafe(Handle myH) = {0xA069, 0x1F00, 0xA064, 0xA029, 0x101F};
  83. #endif
  84.  
  85. /* ClearHiliteMode clears the HiliteMode bit with BCLR */
  86.  
  87. /*pascal void ClearHiliteMode(void) = {0x08B8, 0x0007, 0x0938};
  88. */
  89.  
  90. #define numOfLongs(s)    (((s)>>2) - 1L)
  91.  
  92. #if defined(powerc) || defined (__powerc)
  93. void MyZeroBuffer(long *p, long s);
  94. void MyFillBuffer(long *p, long s, long filler);
  95. long mySwap(long s);
  96. #else
  97. #pragma parameter MyZeroBuffer(__A0,__D1)
  98. extern pascal void MyZeroBuffer(long *p, long s) = {0x7000, 0x20C0, 0x51C9, 0xFFFC };
  99.  
  100. #pragma parameter MyFillBuffer(__A0,__D1,__D0)
  101. extern pascal void MyFillBuffer(long *p, long s, long filler) = {0x20C0, 0x51C9, 0xFFFC };
  102.  
  103. #pragma parameter __D0 mySwap(__D0)
  104. extern pascal long mySwap(long s) = {0x4840 };
  105. #endif
  106.  
  107.  
  108. /*#pragma parameter __D0 Ext12(__D0)
  109. pascal short Ext12(short s) = {0xE948, 0xE840 };
  110.  
  111. #pragma parameter __D0 Ext11(__D0)
  112. pascal short Ext11(short s) = {0xEB48, 0xEA40 };
  113. */
  114.  
  115. #define    CHARFROMMESSAGE(mess)    (*(((unsigned char *)(&(mess))) + 3))
  116.  
  117. #define MAX(a, b)    ((a) > (b) ? (a) : (b))
  118. #define MIN(a, b)    ((a) < (b) ? (a) : (b))
  119.  
  120. /* strings */
  121. enum simplestrings {
  122. kSTR_NOOPENORPRINT = -16397,
  123. kSTR_ApplicationName = -16396
  124. };
  125.  
  126. enum {
  127. kEscapeKey = 0x351B
  128. };
  129.  
  130. /* for KeyState */
  131. enum {
  132. kCommandKeyCode = 55,
  133. kShiftKeyCode,
  134. kCapsLockKeyCode,
  135. kOptionKeyCode,
  136. kControlKeyCode
  137. };
  138.  
  139. enum {
  140. kWantRestart = false,
  141. kWantShutdown = true
  142. };
  143.  
  144. enum {
  145. kCreat = 'FABR',
  146. kAEAlert = 'ALRT'
  147. };
  148.  
  149. enum {
  150. kSTR_RegDECALLOWED = 302,
  151. kDLOG_Register = 300,
  152. kALRT_REGCANNOTREPLACE = 201,
  153. kALRT_REGSUCCESSSAVED = 202,
  154. kALRT_REGDISKFULL = 203,
  155. kALRT_REGUNKNOWNWRITEERROR = 204,
  156. kALRT_REGCOULDNOTOPENFORWRITING = 205,
  157. kALRT_REGCOULDNOTCREATE = 206,
  158. kItemUserName = 3,
  159. kItemCompany,
  160. kItemAddress,
  161. kItemCity,
  162. kItemState,
  163. kItemZIP,
  164. kItemCountry,
  165. kItemE_mail,
  166. kItemPhone,
  167. kItemFAX,
  168. kItemQuantity,
  169. kItemCopyFrom,
  170. kItemComments,
  171. kItemTotals = 28
  172. };
  173.  
  174. OSErr AddSTRRes2Doc(FSSpec *theDoc, OSType myFcrea, OSType myFtype, short STRid, ScriptCode lScript);
  175. OSErr AddSTRHand2Doc(FSSpec *theDoc, OSType myFcrea, OSType myFtype, StringHandle msgString, ScriptCode lScript);
  176. OSErr AddRes2Doc(FSSpec *theDoc, Handle thisHandle, ResType rType, short rID);
  177. void SendmyAE(AEEventClass, AEEventID myAEvtID, AEIdleProcPtr, AESendMode theMode);
  178. void SendmyAEPShort(AEEventClass myclass, AEEventID myAEvtID, AEIdleProcPtr IdleFunct, AESendMode theMode, short theAlert);
  179. void ZoomRectToRect(RectPtr startingRect, RectPtr endingRect, short numofDivs);
  180. void ZoomRectToRectAutoGrafPort(RectPtr startingRect, RectPtr endingRect, short numofDivs);
  181. Handle NewHandleGeneral(Size blockSize);
  182. Handle Get1ResGeneral(ResType theType, short theID);
  183. OSType FindFinderAtEaseProcess(ProcessSerialNumber *);
  184. OSType FindFinderProcess(void);
  185. OSErr SendShutdownToFinder(AEIdleProcPtr, Boolean);
  186. short StopAlert_UPP(short alertID, ModalFilterProcPtr filterProc);
  187. short StopAlert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  188. short CautionAlert_UPP(short alertID, ModalFilterProcPtr filterProc);
  189. short CautionAlert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  190. short NoteAlert_UPP(short alertID, ModalFilterProcPtr filterProc);
  191. short NoteAlert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  192. short Alert_UPP(short alertID, ModalFilterProcPtr filterProc);
  193. short Alert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  194.  
  195. typedef struct {
  196.     FSSpec    destFile;
  197.     ScriptCode    theScript;
  198.     } StdFileResult, *StdFileResultPtr;
  199.  
  200. /* dialog box manager */
  201.  
  202. struct dialogitems {
  203.     short    itemNumber;
  204.     short    group;
  205.     long    refCon;
  206.     };
  207.  
  208. typedef struct dialogitems dialogItems, *dialogItemsPtr;
  209.  
  210. void FlashButton(DialogPtr dlg, short item);
  211. void OutlineButton(DialogPtr oftheDialog, short myItem);
  212.  
  213. short HandleDialog(ModalFilterProcPtr filterProc,
  214.                     dialogItemsPtr things,
  215.                     void (*initProc)(DialogPtr),
  216.                     void (*userProc)(DialogPtr, Handle, short),
  217.                     short resId);
  218.  
  219. /* about box manager */
  220.  
  221. void myAbout(void (*theIdleProc)(void),
  222.             UserItemUPP DrawQTPict,
  223.             void (*UpdateProc)(EventRecord *),
  224.             void (*ActivateProc)(EventRecord *)
  225.             );
  226. Handle OpenSplash(DialogPtr *, UserItemUPP DrawQTPict);
  227. void DisposeSplash(Handle, DialogPtr);
  228.  
  229. Boolean GetFontNumber(ConstStr255Param fontName, short *fontNum);
  230. OSErr TickleParent( FSSpec *child );
  231. Boolean CmdPeriod(EventRecord *theEvent);
  232. Boolean CmdPeriodOrEsc(EventRecord *theEvent);
  233. Boolean CmdPeriodOrEscConfirm(EventRecord *theEvent, short alertID, ModalFilterProcPtr filterProc);
  234. void HandleRegistration(ModalFilterProcPtr filterProc,
  235.                         long (*regCfgInfo)(Handle, long, StringPtr),
  236.                         short dollars);
  237. void RegInitProc(DialogPtr myDPtr);
  238. OSErr AskForDestFile(StdFileResultPtr whichFile, Ptr prompt, Ptr docName);
  239. void BCDVersNumToString(long num, StringPtr str);
  240. void BCDLongVersNumToString(long num, StringPtr str);
  241. Boolean TrapAvailable(short theTrap);
  242. OSErr InstallRequiredAEHandlers(AEEventHandlerProcPtr myOAPP,
  243.                                 AEEventHandlerProcPtr myODOC,
  244.                                 AEEventHandlerProcPtr myPDOC,
  245.                                 AEEventHandlerProcPtr myQUIT);
  246.  
  247.